/*
 * @Descripttion: 重构Console方法
 * @Version: 1.0
 * @Author: undead
 * @Date: 2021-03-25 16:00:36
 * @LastEditors: undead
 * @LastEditTime: 2021-04-09 16:24:57
 */
import logger from "./logger";

interface INewConsole {
    memory: any;
    assert(condition?: boolean, ...data: any[]): void;
    clear(): void;
    count(label?: string): void;
    countReset(label?: string): void;
    debug(...data: any[]): void;
    dir(item?: any, options?: any): void;
    dirxml(...data: any[]): void;
    error(...data: any[]): void;
    exception(message?: string, ...optionalParams: any[]): void;
    group(...data: any[]): void;
    groupCollapsed(...data: any[]): void;
    groupEnd(): void;
    info(...data: any[]): void;
    log(...data: any[]): void;
    table(tabularData?: any, properties?: string[]): void;
    time(label?: string): void;
    timeEnd(label?: string): void;
    timeLog(label?: string, ...data: any[]): void;
    timeStamp(label?: string): void;
    trace(...data: any[]): void;
    warn(...data: any[]): void;
}
const { log, info, error, warn, debug }: INewConsole = console;
export default class NewConsole {
    constructor() {
        const proptoTypes = Object.getPrototypeOf(this);
        for (let key in proptoTypes) {
            if (typeof proptoTypes[key] === "function") {
                console[key] = proptoTypes[key].bind(this);
            }
        }
    }
    log(...data: any[]): void {
        logger.addConsoleLog(data);
        log(...["🟢", ...data]);
    }
    info(...data: any[]): void {
        logger.addConsoleInfo(data);
        info(...["🔵", ...data]);
    }
    error(...data: any[]): void {
        logger.addConsoleError(data);
        error(...["🔴", ...data]);
    }
    warn(...data: any[]): void {
        logger.addConsoleWarn(data);
        warn(...["🟡", ...data]);
    }
    debug(...data: any[]): void {
        debug(...["🟠", ...data]);
    }
}
